<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>简易计算器</title>
    <script>
        function fn(operator){
            let num1 = document.getElementById("num1").value;
            let num2 = document.getElementById("num2").value;
            let result = document.getElementById("result");
            if(operator == "+"){
                result.innerHTML = parseFloat(num1) + parseFloat(num2);
            }
            if(operator == "-"){
                result.innerHTML = parseFloat(num1) - parseFloat(num2);
            }
            if(operator == "*"){
                result.innerHTML = parseFloat(num1) * parseFloat(num2);
            }
            if(operator == "/"){
                result.innerHTML = parseFloat(num1) / parseFloat(num2);
            }
        }
    </script>
</head>
<body>
<table>
    <tr>
        <td>第一个数:</td>
        <td>
            <input type="text" id="num1">
        </td>
    </tr>
    <tr>
        <td>第二个数:</td>
        <td>
            <input type="text" id="num2">
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <input type="button" value="     +     " onclick="fn('+')">
            <input type="button" value="     -     " onclick="fn('-')">
            <input type="button" value="     *     " onclick="fn('*')">
            <input type="button" value="     /     " onclick="fn('/')">
        </td>
    </tr>
    <tr>
        <td>计算结果:</td>
        <td><span id="result"></span></td>
    </tr>
</table>
</body>
</html>